#Importing Scripts
file = "/home/CAMPUS/mwl04747/github/Climate_Change_Narratives/Olivia/856083.csv"
import = read.csv(file)
plot(TMAX~DATE, import)
What’s going on? What is the deal with the -9999? These are used for missing data. We need to remove them!
import$TMAX[import$TMAX==-9999] = NA
import$TMIN[import$TMIN==-9999] = NA
Okay, now we’ll check again, for dates less then Dec. 31, 1913:
plot(TMAX~DATE, import[import$DATE<19131231,], ty='l')
Yikes! What’s wrong? As it turns it the problem is that with how the dates are specified. In particular, the Dec 31 to Jan 1 transition:
19132131 -> 19140101, if you use these as numbers it should be 19131232, 19131232, etc. You see we are missing lots numbers!
plot(TMAX~DATE, import[import$DATE<19130102,], ty='l')
First, we convert the date a string or character values. Next, we’ll convert the strings to a data format.
strDates <- as.character(import$DATE)
head(strDates)
## [1] "19481101" "19481102" "19481103" "19481104" "19481105" "19481106"
import$NewDate <- as.Date(strDates, "%Y%m%d")
plot(TMAX~NewDate, import[import$DATE<19130102,], ty='l')
## Subset Sites
Olivia has two sites in here data, so, we need to subset it.
unique(import$STATION_NAME)
## [1] POUGHKEEPSIE AIRPORT NY US POUGHKEEPSIE NY US
## Levels: POUGHKEEPSIE AIRPORT NY US POUGHKEEPSIE NY US
Let’s choose the POUGHKEEPSIE NY US because the record is longer than the airport.
poughkeepsie <- subset(import, STATION_NAME=="POUGHKEEPSIE NY US", select=c(STATION, STATION_NAME, LONGITUDE, LATITUDE, ELEVATION, DATE, NewDate, TMIN, TMAX))
## A new plot
plot(TMAX~NewDate, poughkeepsie, ty='l')
Creating a linear model and then evaluate the rate (slope).
# Linear Model
poughkeepsie.lm <- lm(TMAX~NewDate, data=poughkeepsie)
summary(poughkeepsie.lm)
##
## Call:
## lm(formula = TMAX ~ NewDate, data = poughkeepsie)
##
## Residuals:
## Min 1Q Median 3Q Max
## -69.571 -9.611 0.960 10.001 24.935
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.683e+01 1.355e-01 124.161 < 2e-16 ***
## NewDate 4.796e-05 1.041e-05 4.609 4.07e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11.3 on 18159 degrees of freedom
## (206 observations deleted due to missingness)
## Multiple R-squared: 0.001169, Adjusted R-squared: 0.001113
## F-statistic: 21.24 on 1 and 18159 DF, p-value: 4.072e-06
plot(TMAX~NewDate, poughkeepsie, ty='l')
abline(coef(poughkeepsie.lm), col='red')
So, let’s figure out how to see how changes happen for individual months.
# Get months
poughkeepsie$Month = months(poughkeepsie$NewDate)
poughkeepsie$Year = format(poughkeepsie$NewDate, format="%Y")
MonthlyMean = aggregate(TMAX ~ Month + Year, poughkeepsie, mean)
MonthlyMean$YEAR = as.numeric(MonthlyMean$Year)
head(MonthlyMean)
## Month Year TMAX YEAR
## 1 April 1893 14.630000 1893
## 2 August 1893 29.196774 1893
## 3 December 1893 4.416667 1893
## 4 February 1893 1.721429 1893
## 5 January 1893 -2.522581 1893
## 6 July 1893 29.696774 1893
plot(MonthlyMean$TMAX, ty='l')
plot(MonthlyMean$TMAX[MonthlyMean$Month=="January"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="January",], ty='l')
January.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="January",])
summary(January.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "January", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.1287 -1.3260 -0.1033 1.4961 5.9153
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.944983 30.760238 -0.323 0.748
## YEAR 0.006111 0.015840 0.386 0.701
##
## Residual standard error: 2.546 on 48 degrees of freedom
## Multiple R-squared: 0.003092, Adjusted R-squared: -0.01768
## F-statistic: 0.1489 on 1 and 48 DF, p-value: 0.7013
abline(coef(January.lm), col="red")
Now, the change is 0.0061114 degress/year or 0.611 degress/100 years with a probability of 0.7013.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="February"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="February",], ty='l')
February.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="February",])
summary(February.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "February", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.7936 -1.5877 0.3748 1.1942 5.7732
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -48.46574 25.01960 -1.937 0.0585 .
## YEAR 0.02652 0.01289 2.059 0.0449 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.076 on 49 degrees of freedom
## Multiple R-squared: 0.0796, Adjusted R-squared: 0.06081
## F-statistic: 4.238 on 1 and 49 DF, p-value: 0.04488
abline(coef(February.lm), col="red")
Now, the change is 0.0265246 degress/year or 2.652 degress/100 years with a probability of 0.0449.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="March"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="March",], ty='l')
March.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="March",])
summary(March.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "March", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.4234 -1.8292 -0.2731 1.3622 7.3096
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -42.58376 31.07800 -1.370 0.177
## YEAR 0.02621 0.01601 1.638 0.108
##
## Residual standard error: 2.579 on 49 degrees of freedom
## Multiple R-squared: 0.0519, Adjusted R-squared: 0.03256
## F-statistic: 2.683 on 1 and 49 DF, p-value: 0.1079
abline(coef(March.lm), col="red")
Now, the change is 0.0262142 degress/year or 2.621 degress/100 years with a probability of 0.1079.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="April"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="April",], ty='l')
April.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="April",])
summary(April.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "April", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2601 -1.2442 -0.1452 0.9025 6.7899
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -32.48310 24.14796 -1.345 0.1848
## YEAR 0.02501 0.01244 2.010 0.0499 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.977 on 49 degrees of freedom
## Multiple R-squared: 0.07619, Adjusted R-squared: 0.05734
## F-statistic: 4.041 on 1 and 49 DF, p-value: 0.04992
abline(coef(April.lm), col="red")
Now, the change is 0.0061114 degress/year or 2.501 degress/100 years with a probability of 0.0499.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="May"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="May",], ty='l')
May.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="May",])
summary(May.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "May", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8459 -1.7251 -0.1127 1.1418 5.3706
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.628966 25.957324 0.140 0.889
## YEAR 0.009819 0.013372 0.734 0.466
##
## Residual standard error: 2.119 on 48 degrees of freedom
## Multiple R-squared: 0.01111, Adjusted R-squared: -0.009494
## F-statistic: 0.5392 on 1 and 48 DF, p-value: 0.4664
abline(coef(May.lm), col="red")
plot(MonthlyMean$TMAX[MonthlyMean$Month=="June"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="June",], ty='l')
June.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="June",])
summary(January.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "January", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.1287 -1.3260 -0.1033 1.4961 5.9153
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.944983 30.760238 -0.323 0.748
## YEAR 0.006111 0.015840 0.386 0.701
##
## Residual standard error: 2.546 on 48 degrees of freedom
## Multiple R-squared: 0.003092, Adjusted R-squared: -0.01768
## F-statistic: 0.1489 on 1 and 48 DF, p-value: 0.7013
abline(coef(June.lm), col="red")
Now, the change is 0.0180432 degress/year or 1.804 degress/100 years with a probability of 0.0701.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="July"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="July",], ty='l')
July.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="July",])
summary(July.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "July", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8341 -0.6668 0.1047 0.7091 3.1579
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.511347 15.319454 -0.294 0.770
## YEAR 0.017781 0.007891 2.253 0.029 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.203 on 47 degrees of freedom
## Multiple R-squared: 0.09749, Adjusted R-squared: 0.07829
## F-statistic: 5.077 on 1 and 47 DF, p-value: 0.02895
abline(coef(July.lm), col="red")
Now, the change is 0.0177806 degress/year or 1.778 degress/100 years with a probability of 0.029.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="August"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="August",], ty='l')
August.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="August",])
summary(August.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "August", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.24628 -0.67688 0.04388 0.83274 2.79410
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.05892 15.00930 -0.604 0.549
## YEAR 0.01950 0.00773 2.523 0.015 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.186 on 48 degrees of freedom
## Multiple R-squared: 0.1171, Adjusted R-squared: 0.09871
## F-statistic: 6.367 on 1 and 48 DF, p-value: 0.015
abline(coef(August.lm), col="red")
Now, the change is 0.0195043 degress/year or 1.95 degress/100 years with a probability of 0.015.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="September"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="September",], ty='l')
September.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="September",])
summary(September.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "September", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.2051 -1.0808 -0.2537 1.1669 4.1108
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.21443 21.31950 -0.151 0.881
## YEAR 0.01431 0.01098 1.304 0.199
##
## Residual standard error: 1.68 on 47 degrees of freedom
## Multiple R-squared: 0.03489, Adjusted R-squared: 0.01436
## F-statistic: 1.699 on 1 and 47 DF, p-value: 0.1987
abline(coef(September.lm), col="red")
Now, the change is 0.0143109 degress/year or 1.431 degress/100 years with a probability of 0.1987.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="October"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="October",], ty='l')
October.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="October",])
summary(October.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "October", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.0260 -0.8934 -0.1299 1.0138 4.1664
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -43.95499 20.48272 -2.146 0.03707 *
## YEAR 0.03219 0.01055 3.050 0.00375 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.595 on 47 degrees of freedom
## Multiple R-squared: 0.1653, Adjusted R-squared: 0.1475
## F-statistic: 9.305 on 1 and 47 DF, p-value: 0.00375
abline(coef(October.lm), col="red")
Now, the change is 0.0321865 degress/year or 3.219 degress/100 years with a probability of 0.0038.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="November"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="November",], ty='l')
November.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="November",])
summary(November.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "November", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.1245 -1.6139 -0.1612 1.2164 5.7890
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -43.56313 23.50500 -1.853 0.0700 .
## YEAR 0.02813 0.01211 2.324 0.0244 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.858 on 48 degrees of freedom
## Multiple R-squared: 0.1011, Adjusted R-squared: 0.08241
## F-statistic: 5.401 on 1 and 48 DF, p-value: 0.02441
abline(coef(November.lm), col="red")
Now, the change is 0.0281327 degress/year or 2.813 degress/100 years with a probability of 0.0244.
plot(MonthlyMean$TMAX[MonthlyMean$Month=="December"], ty='l')
plot(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="December",], ty='l')
December.lm <- lm(TMAX~YEAR, data=MonthlyMean[MonthlyMean$Month=="December",])
summary(December.lm)
##
## Call:
## lm(formula = TMAX ~ YEAR, data = MonthlyMean[MonthlyMean$Month ==
## "December", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6681 -1.1900 -0.1483 1.6416 3.7309
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 26.95757 25.72931 1.048 0.300
## YEAR -0.01183 0.01325 -0.892 0.377
##
## Residual standard error: 2.034 on 48 degrees of freedom
## Multiple R-squared: 0.01632, Adjusted R-squared: -0.004172
## F-statistic: 0.7964 on 1 and 48 DF, p-value: 0.3766
abline(coef(December.lm), col="red")
Now, the change is -0.0118253 degress/year or -1.183 degress/100 years with a probability of 0.3766.
MonthlyMeanTMIN = aggregate(TMIN ~ Month + Year, poughkeepsie, mean)
MonthlyMeanTMIN$YEAR = as.numeric(MonthlyMeanTMIN$Year)
head(MonthlyMeanTMIN)
## Month Year TMIN YEAR
## 1 April 1893 1.186667 1893
## 2 August 1893 13.700000 1893
## 3 December 1893 -7.856667 1893
## 4 February 1893 -10.750000 1893
## 5 January 1893 -15.593548 1893
## 6 July 1893 12.383871 1893
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="January"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="January",], ty='l')
Jan.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="January",])
summary(Jan.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "January", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.3746 -1.9704 0.1447 1.7444 6.7812
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -47.05030 37.23742 -1.264 0.213
## YEAR 0.01993 0.01918 1.039 0.304
##
## Residual standard error: 3.082 on 48 degrees of freedom
## Multiple R-squared: 0.02201, Adjusted R-squared: 0.001632
## F-statistic: 1.08 on 1 and 48 DF, p-value: 0.3039
abline(coef(Jan.lm), col="red")
We get a slope, 0.0199282 degress/year and a probability of 0.3038818 and an r-sqaured of 0.022
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="February"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="February",], ty='l')
Feb.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="February",])
summary(Feb.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "February", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.7811 -1.2847 0.3238 1.8129 5.2739
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -102.21390 35.45077 -2.883 0.00583 **
## YEAR 0.04857 0.01826 2.660 0.01052 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.942 on 49 degrees of freedom
## Multiple R-squared: 0.1262, Adjusted R-squared: 0.1084
## F-statistic: 7.077 on 1 and 49 DF, p-value: 0.01052
abline(coef(Feb.lm), col="red")
We get a slope, 0.04857 degress/year and a probability of 0.0105224 and an r-sqaured of 0.126
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="March"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="March",], ty='l')
Mar.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="March",])
summary(Mar.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "March", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6665 -1.3535 0.0593 1.1247 5.3864
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -70.90530 24.34291 -2.913 0.00542 **
## YEAR 0.03500 0.01254 2.792 0.00749 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.015 on 48 degrees of freedom
## Multiple R-squared: 0.1397, Adjusted R-squared: 0.1218
## F-statistic: 7.797 on 1 and 48 DF, p-value: 0.007492
abline(coef(Mar.lm), col="red")
We get a slope, 0.0350021 degress/year and a probability of 0.0074921 and an r-sqaured of 0.14
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="April"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="April",], ty='l')
Apr.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="April",])
summary(Apr.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "April", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.4574 -1.0518 -0.0836 1.2573 5.0090
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -79.96506 24.49298 -3.265 0.0020 **
## YEAR 0.04275 0.01262 3.388 0.0014 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.005 on 49 degrees of freedom
## Multiple R-squared: 0.1898, Adjusted R-squared: 0.1733
## F-statistic: 11.48 on 1 and 49 DF, p-value: 0.001397
abline(coef(Apr.lm), col="red")
We get a slope, 0.0427538 degress/year and a probability of 0.001397 and an r-sqaured of 0.19
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="May"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="May",], ty='l')
May.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="May",])
summary(May.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "May", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.5306 -0.7823 0.0656 0.9126 4.6292
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -19.345918 17.589376 -1.100 0.277
## YEAR 0.014523 0.009061 1.603 0.116
##
## Residual standard error: 1.436 on 48 degrees of freedom
## Multiple R-squared: 0.0508, Adjusted R-squared: 0.03102
## F-statistic: 2.569 on 1 and 48 DF, p-value: 0.1156
abline(coef(May.lm), col="red")
We get a slope, 0.0145231 degress/year and a probability of 0.1155535 and an r-sqaured of 0.051
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="June"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="June",], ty='l')
Jun.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="June",])
summary(Jun.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "June", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.14678 -0.57845 0.02714 0.74396 2.43635
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -26.496164 15.054023 -1.760 0.08490 .
## YEAR 0.020823 0.007752 2.686 0.00996 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.186 on 47 degrees of freedom
## Multiple R-squared: 0.1331, Adjusted R-squared: 0.1146
## F-statistic: 7.216 on 1 and 47 DF, p-value: 0.009958
abline(coef(Jun.lm), col="red")
We get a slope, 0.0208234 degress/year and a probability of 0.0099582 and an r-sqaured of 0.133
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="July"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="July",], ty='l')
Jul.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="July",])
summary(Jul.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "July", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8815 -0.6664 0.0747 0.9668 2.2956
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -35.029234 18.504165 -1.893 0.06452 .
## YEAR 0.026682 0.009532 2.799 0.00741 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.453 on 47 degrees of freedom
## Multiple R-squared: 0.1429, Adjusted R-squared: 0.1247
## F-statistic: 7.836 on 1 and 47 DF, p-value: 0.007406
abline(coef(Jul.lm), col="red")
We get a slope, 0.0266817 degress/year and a probability of 0.0074064 and an r-sqaured of 0.143
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="August"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="August",], ty='l')
Aug.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="August",])
summary(Aug.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "August", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.9768 -1.0045 -0.0062 0.7076 3.5140
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -15.128441 18.276565 -0.828 0.4119
## YEAR 0.015900 0.009413 1.689 0.0977 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.445 on 48 degrees of freedom
## Multiple R-squared: 0.05611, Adjusted R-squared: 0.03645
## F-statistic: 2.854 on 1 and 48 DF, p-value: 0.09766
abline(coef(Aug.lm), col="red")
We get a slope, 0.0159002 degress/year and a probability of 0.0976612 and an r-sqaured of 0.056
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="September"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="September",], ty='l')
Sep.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="September",])
summary(Sep.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "September", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2245 -0.9323 -0.0338 1.1739 2.7668
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -42.673779 18.449799 -2.313 0.02506 *
## YEAR 0.027969 0.009502 2.944 0.00499 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.458 on 48 degrees of freedom
## Multiple R-squared: 0.1529, Adjusted R-squared: 0.1353
## F-statistic: 8.664 on 1 and 48 DF, p-value: 0.004988
abline(coef(Sep.lm), col="red")
We get a slope, 0.0279689 degress/year and a probability of 0.0049877 and an r-sqaured of 0.153
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="October"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="October",], ty='l')
Oct.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="October",])
summary(Oct.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "October", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.7786 -0.8750 -0.0323 0.9936 3.0277
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -59.660216 18.370814 -3.248 0.002151 **
## YEAR 0.033635 0.009464 3.554 0.000877 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.431 on 47 degrees of freedom
## Multiple R-squared: 0.2118, Adjusted R-squared: 0.1951
## F-statistic: 12.63 on 1 and 47 DF, p-value: 0.0008765
abline(coef(Oct.lm), col="red")
We get a slope, 0.0336353 degress/year and a probability of 8.76510^{-4} and an r-sqaured of 0.212
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="November"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="November",], ty='l')
Nov.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="November",])
summary(Nov.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "November", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.5789 -1.0381 -0.0941 0.7474 4.7307
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -66.49796 21.83632 -3.045 0.00377 **
## YEAR 0.03450 0.01125 3.068 0.00354 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.726 on 48 degrees of freedom
## Multiple R-squared: 0.1639, Adjusted R-squared: 0.1465
## F-statistic: 9.412 on 1 and 48 DF, p-value: 0.003538
abline(coef(Nov.lm), col="red")
We get a slope, 0.0345023 degress/year and a probability of 0.0035375 and an r-sqaured of 0.164
plot(MonthlyMeanTMIN$TMIN, ty='l')
plot(MonthlyMeanTMIN$TMIN[MonthlyMeanTMIN$Month=="December"], ty='l')
plot(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="December",], ty='l')
Dec.lm <- lm(TMIN~YEAR, data=MonthlyMeanTMIN[MonthlyMeanTMIN$Month=="December",])
summary(Dec.lm)
##
## Call:
## lm(formula = TMIN ~ YEAR, data = MonthlyMeanTMIN[MonthlyMeanTMIN$Month ==
## "December", ])
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.2446 -1.3984 0.2842 1.4262 3.7928
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -24.261197 28.538284 -0.850 0.399
## YEAR 0.009539 0.014698 0.649 0.519
##
## Residual standard error: 2.256 on 48 degrees of freedom
## Multiple R-squared: 0.008699, Adjusted R-squared: -0.01195
## F-statistic: 0.4212 on 1 and 48 DF, p-value: 0.5194
abline(coef(Dec.lm), col="red")
In this case, we get a slope, 0.009539 degress/year and a probability of 0.5194195 and an r-sqaured of 0.009. Cool! As we might expect, the a small amount of the variance is explained by the “Month”. Many things predict temerpature, that year is one, is quite problematic.
What we have not determined is the cause. So, be careful when you describe the results, cause and effect cannot be analyzed using this method.